package com.itcat.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itcat.api.mysql.UsmResourceApi;
import com.itcat.common.CommonPage;
import com.itcat.mysql.pojo.UmsMenu;
import com.itcat.mysql.pojo.UmsResource;
import com.itcat.service.UsmResourceService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * [一句话描述该类的功能]
 *
 * @author : [Cr Mr]
 * @version : [v1.0]
 * @date : [2022/4/3 19:24]
 */
@Service
public class UsmResourceServiceImpl implements UsmResourceService {

    @DubboReference
    private UsmResourceApi usmResourceApi;

    /***
     * 添加后台资源
     * @author Cr Mr
     * @date 2022/4/3 19:30
     */
    @Override
    public void create(UmsResource umsResource) {
        usmResourceApi.create(umsResource);
    }

    /***
     * 分页模糊查询后台资源
     * @author Cr Mr
     * @date 2022/4/3 19:35
     */
    @Override
    public CommonPage<UmsResource> list(Long categoryId, String nameKeyword, String urlKeyword, Integer pageNum, Integer pageSize) {
        Page<UmsResource> selectPage = usmResourceApi.selectPage(categoryId, nameKeyword, urlKeyword, pageNum, pageSize);
        CommonPage<UmsResource> page = CommonPage.restPage(selectPage);
        return page;
    }

    /***
     * 根据ID删除后台资源
     * @author Cr Mr
     * @date 2022/4/3 19:55
     */
    @Override
    public void delete(Long id) {
        usmResourceApi.delete(id);
    }

    /***
     * 查询所有后台资源
     * @author Cr Mr
     * @date 2022/4/3 19:27
     */
    @Override
    public List<UmsResource> listAll() {
        return usmResourceApi.listAll();
    }

    /***
     * 修改后台资源
     * @author Cr Mr
     * @date 2022/4/3 19:26
     */
    @Override
    public void update(Long id, UmsResource umsResource) {
        usmResourceApi.update(id, umsResource);
    }

    /***
     * 根据ID获取资源详情
     * @author Cr Mr
     * @date 2022/4/3 19:29
     */
    @Override
    public UmsResource resource(Long id) {
        return usmResourceApi.resource(id);
    }
}
